package ThinkInJava;
/**
 * 多态
 * @author Administrator
 *
 */
public class Base
{
    private String baseName = "base";
    public Base()
    {
        callName();
    }
 
    public void callName()
    {
        System. out. println(baseName);
    }
 
    static class Sub extends Base
    {
        private String baseName = "sub";
        public void callName()
        {
            System. out. println (baseName) ;
        }
    }
    public static void main(String[] args)
    {
    	//这两个输出null，因为构造sub的时候肯定要先构造基类，而由于多态，导致子类的baseName为null
    	//故输出也为null
        //Sub b = new Sub();
    	//Base b = new Sub();
    	//此项输出base
    	Base b = new Base();
    }
}
